<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html {
      --main-color: #f00;
    }

    .box {
      color: var(--main-color);
    }

    .title {
      color: var(--main-color);
    }
  </style>
</head>
<body>
  <div class="box">
    我是box
  </div>
  <h1 class="title">我是标题</h1>
</body>
</html>